package com.teach;

/**
 * <pre>
 * - 包装器类和基本数据类型的转换
 * Author : J.L.Zhou
 * E-Mail : 2233875735@qq.com
 * Tel : 151 1104 7708
 * Date : 2021-04-12 11:11
 * Version : 1.0
 * Copyright 2021 jlzhou.top Inc. All rights reserved.
 * Warning: this content is only for internal circulation of the company.
 *          It is forbidden to divulge it or use it for other commercial purposes.
 * </pre>
 **/
public class Demo01 {

  public static void main(String[] args) {
    //转包装器
    boolean b1 = true;
    Boolean b2 = new Boolean(b1);

    char c1 = 'a';
    Character c2 = new Character(c1);

    int i1 = 1;
    Integer i2 = new Integer(i1);

    //转基本数据类型
    boolean b3 = b2.booleanValue();
    char c3 = c2.charValue();
    int i3 = i2.intValue();

    //JDK1.5+
    b2 = b1;//把基本数据类型的变量赋值给对应的包装器类的变量:自动装箱
    //b2 = new Boolean(b1);
    b1 = b2;//把包装器类的变量的对象赋值给对应的基本数据类型的变量:自动拆箱
    //b1 = b2.booleanValue();
  }
}
